package com.jbit.dm212.controller;

import cn.hutool.core.bean.BeanUtil;
import com.jbit.dm212.common.ResponseResult;
import com.jbit.dm212.common.ResponseResultUtils;
import com.jbit.dm212.entity.dto.DmCinemaSeatArrayDTO;
import com.jbit.dm212.entity.dto.DmCinemaSeatDTO;
import com.jbit.dm212.entity.po.DmScheduler;
import com.jbit.dm212.entity.vo.DmSchedulerVO;
import com.jbit.dm212.service.DmSchedulerSeatService;
import com.jbit.dm212.service.DmSchedulerService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/scheduler/api/p")
public class DmSchedulerController {
    @Resource
    private DmSchedulerService schedulerService;
    @Resource
    private DmSchedulerSeatService schedulerSeatService;
    @PostMapping("/queryCinemaSeatArrayByScheduleId")
    public ResponseResult<DmCinemaSeatArrayDTO> queryCinemaSeatArrayByScheduleId(@RequestBody DmSchedulerVO schedulerVO){
        DmScheduler scheduler = new DmScheduler();
        BeanUtil.copyProperties(schedulerVO,scheduler);
        scheduler.setId(schedulerVO.getScheduleId());

        return ResponseResultUtils.sendSuccess(schedulerService.getSeatArrayByScheduleId(scheduler));
    }

    @PostMapping("/queryOriginalCinemaSeatArray")
    public ResponseResult<DmCinemaSeatDTO> queryOriginalCinemaSeatArray(@RequestBody DmSchedulerVO schedulerVO){
        DmScheduler scheduler = new DmScheduler();
        BeanUtil.copyProperties(schedulerVO,scheduler);
        scheduler.setId(schedulerVO.getScheduleId());
        return ResponseResultUtils.sendSuccess(schedulerSeatService.getCinemaSeatArray(scheduler));
    }
}
